//
//  UIButton+Extension.swift
//  WearDu
//
//  Created by wang tiao on 2025/3/18.
//

import UIKit


extension UIButton {
    
    convenience init(type: ButtonType = .custom, title: String? = nil, font: UIFont = UIFont.systemFont(ofSize: 15), textColor: UIColor = .black, target: Any? = nil, action: Selector? = nil) {
        self.init(type: type)
        self.titleLabel?.font = font
        self.setTitle(title, for: .normal)
        self.setTitleColor(textColor, for: .normal)
        if let target = target, let action = action {
            self.addTarget(target, action: action, for: .touchUpInside)
        }
    }
    
    convenience init(image: UIImage? = nil, selectedImage: UIImage? = nil, target: Any? = nil, action: Selector? = nil) {
        self.init()
        self.setImage(image, for: .normal)
        self.setImage(selectedImage, for: .selected)
        if let target = target, let action = action {
            self.addTarget(target, action: action, for: .touchUpInside)
        }
    }
    
}
